package com.xja.webchat.service.impl;

import com.xja.webchat.entity.Chatuser;
import com.xja.webchat.mapper.ChatuserMapper;
import com.xja.webchat.service.ChatUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("chatUserService")
public class ChatUserServiceImpl implements ChatUserService {
    @Autowired
    private ChatuserMapper chatuserMapper;

    @Override
    @Transactional(readOnly = true)
    public Chatuser selectUserById(Integer id) throws Exception {
        return chatuserMapper.selectByPrimaryKey(id);
    }

    @Override
    @Transactional(propagation= Propagation.REQUIRED)
    public void addChatuser(Chatuser chatuser) throws Exception {
        chatuserMapper.insertSelective(chatuser);
    }

    @Override
    public List<Chatuser> selectUserAndWdgs(Integer id) throws Exception {
        return chatuserMapper.selectUserAndWdgs(id);
    }

    @Override
    @Transactional(readOnly = true)
    public List<Chatuser> chazhaohaoyou(String keyword) throws Exception {
        return chatuserMapper.chazhaohaoyou(keyword);
    }

    @Override
    @Transactional(propagation= Propagation.REQUIRED)
    public void updateById(Chatuser chatuser) {
        chatuserMapper.updateByPrimaryKeySelective(chatuser);
    }

    @Override
    @Transactional(readOnly = true)
    public Chatuser selectChatuserByuserid(String userid) throws Exception {
        return chatuserMapper.selectChatuserByuserid(userid);
    }
}
